package com.twu.biblioteca;

import com.twu.biblioteca.entity.Movie;
import com.twu.biblioteca.repository.MovieRepository;

import java.util.*;

/**
 * Created by ccsong on 9/22/14.
 */
public class MovieList  implements NormalList
{
    private List<Movie> movieList = new ArrayList<Movie>();
    public MovieList(){
        movieList.add(MovieRepository.movie1);
    }

    @Override
    public String toString(){
        String moviesList = "\n";
        Iterator<Movie> iterator = movieList.listIterator();
        while(iterator.hasNext()){
            moviesList += iterator.next().toString();
        }
        return moviesList;
    }

    @Override
    public boolean containAndCheck(String name) {
        boolean canCheck = false;
        Iterator<Movie> iterator = movieList.listIterator();
        while(iterator.hasNext()){
            if(iterator.next().isMatch(name)){
                canCheck = true;
                break;
            }
        }
        return canCheck;
    }
}
